package com.perceptivesoftware.licensing.client;

import com.google.gwt.core.client.GWT;
import com.perceptivesoftware.licensing.client.rpc.SecurityService;
import com.perceptivesoftware.licensing.client.rpc.SecurityServiceAsync;
import com.perceptivesoftware.licensing.client.rpc.SessionService;
import com.perceptivesoftware.licensing.client.rpc.SessionServiceAsync;
import com.perceptivesoftware.licensing.client.rpc.SystemService;
import com.perceptivesoftware.licensing.client.rpc.SystemServiceAsync;
import com.perceptivesoftware.licensing.client.rpc.TwistageService;
import com.perceptivesoftware.licensing.client.rpc.TwistageServiceAsync;

public class LicensingRPCFactory
{

	private static void resetIf(final boolean isUserInitiatedRPC)
	{
		if (isUserInitiatedRPC)
		{
			PerceptiveUISession.resetLogOff();
		}
	}

	public static SystemServiceAsync getSystemService(final boolean isUserInitiatedRPC)
	{
		resetIf(isUserInitiatedRPC);
		return GWT.create(SystemService.class);
	}

	public static SessionServiceAsync getSessionService(final boolean isUserInitiatedRPC)
	{
		resetIf(isUserInitiatedRPC);
		return GWT.create(SessionService.class);
	}

	public static TwistageServiceAsync getTwistageService(final boolean isUserInitiatedRPC)
	{
		resetIf(isUserInitiatedRPC);
		return GWT.create(TwistageService.class);
	}

	public static SecurityServiceAsync getSecurityService(final boolean isUserInitiatedRPC)
	{
		resetIf(isUserInitiatedRPC);
		return GWT.create(SecurityService.class);
	}

}
